﻿///Name:ClientsAccess类
///Author: 张仪
///Description: 
///Company:河南企汇网信息技术有限公司
///DateTime:2012/7/14 9:46:00


using System;
using System.Data;
using Model.Data;
using Model;
using DataAccess;
using BusinessLogic.BusinessRules;


namespace BusinessLogic.ClassFactory
{
	/// <summary>
	/// ClientsFactory 的摘要说明。
	/// </summary>
	public class ClientsFactory:BaseFactory
	{
		public ClientsFactory() :base()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}
		public ClientsFactory(DBManager  l_DBManager):base(l_DBManager)
		{
		}
		public Clients NewInstance()
		{
			ClientsAccess l_Access = new ClientsAccess(m_Manager);
			Clients objClients=new Clients(this.m_Manager,l_Access);			
			objClients.NewDataSet();
			objClients.SelectRow(0);
			return objClients;
		}

        public int DeleteClientsWhere(string where)
        {
            ClientsAccess l_Access = new ClientsAccess(m_Manager);
            return l_Access.DeleteWhere(where);
        }

		public Clients CreatorBySql(string Sql)
		{
			ClientsAccess l_Access = new ClientsAccess(m_Manager);
			Clients objClients=new Clients(this.m_Manager,l_Access);			
			DataSet l_ds=new ClientsData();
			if(l_Access.QueryBySql(ref l_ds,Sql)<1)
			{
				return  null ;
			}
			objClients.SetDataSet(l_ds);
			objClients.SelectRow(0);
			return objClients;
		}

        public Clients CreatorByFullSql(string Sql)
        {
            ClientsAccess l_Access = new ClientsAccess(m_Manager);
            Clients objClients = new Clients(this.m_Manager, l_Access);
            DataSet l_ds = new ClientsData();
            if (l_Access.QueryByQuerySql(ref l_ds, Sql) < 1)
            {
                return null;
            }
            objClients.SetDataSet(l_ds);
            objClients.SelectRow(0);
            return objClients;
        }

		/// <summary>
		/// 
		/// </summary>
		/// <param name="intClientsID"></param>
		/// <returns></returns>
		public Clients Creator(int intClientsID)
		{
			ClientsAccess l_Access = new ClientsAccess(m_Manager);
			Clients objClients=new Clients(this.m_Manager,l_Access);			
			DataSet l_ds=new ClientsData();
			if(l_Access.QueryByID(ref l_ds,intClientsID)<1)
			{
				return null ;
			}
			objClients.SetDataSet(l_ds);
			objClients.SelectRow(0);
			return objClients;
		}

		public Clients Creator()
		{
			ClientsAccess l_Access = new ClientsAccess(m_Manager);
			Clients objClients=new Clients(this.m_Manager,l_Access);			
			DataSet l_ds=new ClientsData();
			if(l_Access.QueryAll(ref l_ds)<1)
			{
				return null ;
				
			}
			objClients.SetDataSet(l_ds);
			objClients.SelectRow(0);
			return objClients;
		}
		
	}
}
